<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/1/22
 * Time: 14:21
 */
namespace App\Http\Controllers;
use App\Common\Config;
use Illuminate\Support\Facades\Input;
use Laravel\Lumen\Routing\Controller;
use App\Http\Services\ClientService;
class ClientController extends BaseController{
    protected $clientService;
    public function __construct(ClientService $clientService){
        $this->clientService = $clientService;
    }
    /*
     * 获取服务器状态
     */
    public function getStatus(){

        return $this->return_json('0','服务器状态良好');

    }
    /*
     * 用户登录
     */
    public function postLogin(){
        $username = Input::get('username');
        $pwd = Input::get('pwd');
        $result = $this->clientService->login($username,$pwd);
        if($result==false){
            return $this->return_json('1','用户名或密码错误',array('data'=>array()));
        }
        return $this->return_json('0','登录成功',array('data'=>$result));
    }
    /*
     * 获取用户注册地址
     */
    public function reg(){
        $result = $this->clientService->reg();
        return $this->return_json('0','登录成功',array('data'=>$result));
    }
    /*
     * 获取官网地址
     */
    public function website(){
        $result = $this->clientService->website();
        return $this->return_json('0','获取官网地址',array('data'=>$result));
    }
    /*
     * 关于我们
     */
    public function about(){
        $result = $this->clientService->about();
        return $this->return_json('0','关于我们',array('data'=>$result));
    }
    /*
     * 获取导航
     */
    public function nav(){
        $result = $this->clientService->nav();
        return $this->return_json('0','获取导航',array('data'=>$result));
    }
    /*
     * 获取分类
     */
    public function getCategory($type=2,$category=''){
        $result = $this->clientService->getCategory($type,$category);
        return $this->return_json('0','获取分类',array('data'=>$result));
    }
    /*
    * 获取模型风格
    */
    public function getStyle($type=1,$style='style'){
        $result = $this->clientService->getStyle($type,$style);
        return $this->return_json('0','获取风格',array('data'=>$result));
    }
    /*
     * 获取版本
     */
    public function getFormat($type,$format=''){
        $result = $this->clientService->getFormat($type);
        return $this->return_json('0','获取版本',array('data'=>$result));
    }
    /*
     *获取模型/材质/灯光/脚本/贴图/CAD内容
     */
     public function getList($type,$list=''){
         $result = $this->clientService->getList($type,$rows=30);
         $title = "获取导航内容";
         if($type == 1)  $title = '获取贴图内容';
         if($type == 2)  $title = '获取材质内容';
         if($type == 3)  $title = '获取光域网内容';
         if($type == 4)  $title = '获取脚本内容';
         return $this->return_json('0',$title,array('data'=>$result));
     }

}

















